package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.computing.util.EntityConvert;
import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;

public class MaintenanceEvent6Dto {

    private String adasisVersion;
    private String hardwareVersion;
    private String terminalICCID;
    private String locationStatus;
    private String licenseStatus;
    private String simNo;
    private String mapVersion;


    public String getAdasisVersion() {
        return adasisVersion;
    }

    public void setAdasisVersion(String adasisVersion) {
        this.adasisVersion = adasisVersion;
    }

    public String getHardwareVersion() {
        return hardwareVersion;
    }

    public void setHardwareVersion(String hardwareVersion) {
        this.hardwareVersion = hardwareVersion;
    }

    public String getTerminalICCID() {
        return terminalICCID;
    }

    public void setTerminalICCID(String terminalICCID) {
        this.terminalICCID = terminalICCID;
    }

    public String getLocationStatus() {
        return locationStatus;
    }

    public void setLocationStatus(String locationStatus) {
        this.locationStatus = locationStatus;
    }

    public String getLicenseStatus() {
        return licenseStatus;
    }

    public void setLicenseStatus(String licenseStatus) {
        this.licenseStatus = licenseStatus;
    }

    public String getSimNo() {
        return simNo;
    }

    public void setSimNo(String simNo) {
        this.simNo = simNo;
    }

    public String getMapVersion() {
        return mapVersion;
    }

    public void setMapVersion(String mapVersion) {
        this.mapVersion = mapVersion;
    }

    public static MaintenanceEvent6Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent6 maintenanceEvent6){
        MaintenanceEvent6Dto maintenanceEvent6Dto = new MaintenanceEvent6Dto();
        maintenanceEvent6Dto.setAdasisVersion(maintenanceEvent6.getAdasisVersion());
        maintenanceEvent6Dto.setHardwareVersion(maintenanceEvent6.getHardwareVersion());
        maintenanceEvent6Dto.setTerminalICCID(maintenanceEvent6.getTerminalICCID());
        maintenanceEvent6Dto.setLocationStatus(maintenanceEvent6.getLocationStatus());
        maintenanceEvent6Dto.setLicenseStatus(maintenanceEvent6.getLicenseStatus());
        maintenanceEvent6Dto.setSimNo(maintenanceEvent6.getSimNo());
        maintenanceEvent6Dto.setMapVersion(maintenanceEvent6.getMapVersion());
        return maintenanceEvent6Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent6
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent6 maintenanceEvent6){
        return EntityConvert.convert(
                maintenanceEvent6.getAdasisVersion(),
                maintenanceEvent6.getHardwareVersion(),
                maintenanceEvent6.getTerminalICCID(),
                maintenanceEvent6.getLocationStatus(),
                maintenanceEvent6.getLicenseStatus(),
                maintenanceEvent6.getSimNo(),
                maintenanceEvent6.getMapVersion()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent6 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent6.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=7){
                builder =LCPredictiveMaintenance.MaintenanceEvent6.newBuilder();
                builder.setAdasisVersion(String.valueOf(revert[0]));
                builder.setHardwareVersion(String.valueOf(revert[1]));
                builder.setTerminalICCID(String.valueOf(revert[2]));
                builder.setLocationStatus(String.valueOf(revert[3]));
                builder.setLicenseStatus(String.valueOf(revert[4]));
                builder.setMapVersion(String.valueOf(revert[5]));
                builder.setSimNo(String.valueOf(revert[6]));

            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
